package com.mew.common.rest;

import com.mew.common.exception.ResponseCode;
import com.zebra.common.ZebraBaseMessage;
import lombok.*;

/**
 * @Author King.Song
 * @Date 2020/11/7 0007
 **/
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public abstract class MewResponse<T extends MewResponse> extends ZebraBaseMessage<T> {

    private int status = 200;
    private String message = "SUCCESS";

    public  T  buildByResponseCode(ResponseCode responseCode){
        this.setStatus(responseCode.code());
        return (T) this;
    }

    public  T  buildByErrorMessage(String message){
        this.setStatus(500);
        this.message = message;
        return (T) this;
    }

    public  T  buildByErrorMessage(int status,String message){
        this.setStatus(status);
        this.message = message;
        return (T) this;
    }

}
